class ImageController < ApplicationController
  caches_page :large, :small, :mini

  def large
    resize_and_send(params[:id])
  end

  def small
    resize_and_send(params[:id],150)
  end

  def mini
    resize_and_send(params[:id],90)
  end

  private

  def resize_and_send(id,size=0)
    image = Picture.resize(id,size)

    send_data(
      image.to_blob,
      :type => 'image/jpeg',
      :filename => "noname.jpg",
      :disposition => 'inline'
    )
  end
end
